<?php
/**
 * @copyright: ©2024 永州 微聚商网络科技有限公司
 * @link: https://www.wEijuyunke.com
 */
namespace app\api\controller;

use app\BaseController;
use think\App;
use think\facade\Request;
use think\facade\Db;
use think\facade\Log;
use think\Model;
use app\api\controller\Curl;
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true'); // 是否允许后续请求携带认证信息（cookies）,该值只能是true,否则不返回
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); // 允许的请求类型
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
// 允许的请求头字段

/**
 * 首页
 *
 * @author Administrator
 *
 */
class Index extends BaseController
{

    public function updateVersion()
    {
        $curl = new Curl();
        $curl->index();
    }

    public function getVersion()
    {
        $request = $this->request;
        $domain = $request->domain();

        $url = "http://c5.weijuyunke.com/api/softwareApi/pirate";
        $data = array(
            'rjbs' => 'figure_jm',
            'yuming' => $domain
        );
        wtw_request($url, $data);

        $url = "http://c5.weijuyunke.com/api/softwareApi/newest_version";
        $data = array(
            'rjbs' => 'figure_jm',
            'appid' => sysconfig("site", "site_appid"),
            'version' => sysconfig("site", "site_version"),
            'yuming' => $domain
        );
        $result = json_decode(wtw_request($url, $data), true);

        $flag = 0;
        if ($result['code'] == '200') {
            $flag = 1;
        }

        return msg(array(
            'version' => sysconfig("site", "site_version"),
            'flag' => $flag
        ), 0, "success");
    }

    public function versionList()
    {
        $curl = new Curl();
        $versions = $curl->version();

        return msg([
            'list' => $versions
        ], 0, "success");
    }
}